package hong.wei.cheng.suzhoupintan.base;

import android.app.Application;
import android.content.Context;
import android.os.Handler;

import com.ximalaya.ting.android.opensdk.constants.ConstantsOpenSdk;
import com.ximalaya.ting.android.opensdk.constants.DTransferConstants;
import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest;
import com.ximalaya.ting.android.opensdk.player.XmPlayerManager;

import hong.wei.cheng.suzhoupintan.utils.LogUtil;

public class BaseApplication extends Application {

    private static Handler sHandler = null;

    private static Context sContext = null;

    @Override
    public void onCreate() {
        super.onCreate();
        //打开debug 模式
        ConstantsOpenSdk.isDebug = true;

        CommonRequest mXimalaya = CommonRequest.getInstanse();
        if(DTransferConstants.isRelease) {
            String mAppSecret = "892cea0877033f52cc123b5ea3890698";
            mXimalaya.setAppkey("a8511baddb903398af079e89857d1816");
            mXimalaya.setPackid("hong.wei.cheng.suzhoupintan");
            mXimalaya.init(this,mAppSecret);
        } else {
            String mAppSecret = "892cea0877033f52cc123b5ea3890698";
            mXimalaya.setAppkey("a8511baddb903398af079e89857d1816");
            mXimalaya.setPackid("hong.wei.cheng.suzhoupintan");
            mXimalaya.init(this,mAppSecret);
        }

        //初始化播放器
        XmPlayerManager.getInstance(this).init();

        //初始化LogUtil
        LogUtil.init(this.getPackageName(), false);
        sHandler = new Handler();
        sContext = getBaseContext();
    }

    public static Context getAppContext() {
        return sContext;
    }

    public static Handler getHandler() {
        return sHandler;
    }
}
